package com.github.kotvertolet.youtubejextractor.models.newModels;



import com.google.gson.annotations.SerializedName;
import ohos.utils.Parcel;
import ohos.utils.Sequenceable;
import java.io.Serializable;
import com.github.kotvertolet.youtubejextractor.models.youtube.playerResponse.Cipher;

/**
 * 类功能描述(类上)
 *
 * @author AnBetter
 * @since 2021-04-14
 */
public class AdaptiveFormatsItem implements Sequenceable, Serializable {
    @SerializedName(value = "signatureCipher", alternate = {"cipher"})
    private Cipher cipher;
    @SerializedName("itag")
    private int itag = 0;
    @SerializedName("indexRange")
    private IndexRange indexRange;
    @SerializedName("projectionType")
    private String projectionType;
    @SerializedName("initRange")
    private InitRange initRange;
    @SerializedName("bitrate")
    private int bitrate = 0;
    @SerializedName("mimeType")
    private String mimeType;
    @SerializedName("audioQuality")
    private String audioQuality;
    @SerializedName("approxDurationMs")
    private String approxDurationMs;
    @SerializedName("url")
    private String url;
    @SerializedName("audioSampleRate")
    private String audioSampleRate;
    @SerializedName("quality")
    private String quality;
    @SerializedName("audioChannels")
    private int audioChannels = 0;
    @SerializedName("contentLength")
    private String contentLength;
    @SerializedName("lastModified")
    private String lastModified;
    @SerializedName("loudnessDb")
    private float loudnessDb = 0.0f;
    @SerializedName("averageBitrate")
    private int averageBitrate = 0;
    @SerializedName("highReplication")
    private boolean isHighReplication = false;
    @SerializedName("qualityLabel")
    private String qualityLabel;
    @SerializedName("width")
    private int width = 0;
    @SerializedName("fps")
    private int fps = 0;
    @SerializedName("type")
    private String type;
    @SerializedName("height")
    private int height = 0;

    public static final Sequenceable.Producer<AdaptiveFormatsItem> CREATOR = new Producer<AdaptiveFormatsItem>() {
        @Override
        public AdaptiveFormatsItem createFromParcel(Parcel parcel) {
            // Initialize an instance first, then do customized unmarshlling.
            AdaptiveFormatsItem adaptiveFormatsItem = new AdaptiveFormatsItem();
            adaptiveFormatsItem.unmarshalling(parcel);
            return adaptiveFormatsItem;
        }
    };

    @Override
    public boolean marshalling(Parcel parcel) {
        parcel.writeSequenceable(this.cipher);
        parcel.writeInt(this.itag);
        parcel.writeSequenceable(this.indexRange);
        parcel.writeString(this.projectionType);
        parcel.writeSequenceable(this.initRange);
        parcel.writeInt(this.bitrate);
        parcel.writeString(this.mimeType);
        parcel.writeString(this.audioQuality);
        parcel.writeString(this.approxDurationMs);
        parcel.writeString(this.url);
        parcel.writeString(this.audioSampleRate);
        parcel.writeString(this.quality);
        parcel.writeInt(this.audioChannels);
        parcel.writeString(this.contentLength);
        parcel.writeString(this.lastModified);
        parcel.writeInt(this.averageBitrate);
        parcel.writeBoolean(this.isHighReplication);
        parcel.writeString(this.qualityLabel);
        parcel.writeInt(this.width);
        parcel.writeInt(this.fps);
        parcel.writeInt(this.width);
        parcel.writeString(this.type);
        parcel.writeInt(this.height);
        return true;
    }

    @Override
    public boolean unmarshalling(Parcel parcel) {
        parcel.writeSequenceable(this.cipher);
        this.itag=parcel.readInt();
        parcel.readSequenceable(this.indexRange);
        this.projectionType=parcel.readString();
        parcel.readSequenceable(this.initRange);
        this.bitrate=parcel.readInt();
        this.mimeType=parcel.readString();
        this.audioQuality=parcel.readString();
        this.approxDurationMs=parcel.readString();
        this.url=parcel.readString();
        this.audioSampleRate=parcel.readString();
        this.quality=parcel.readString();
        this.audioChannels=parcel.readInt();
        this.contentLength=parcel.readString();
        this.lastModified=parcel.readString();
        this.averageBitrate=parcel.readInt();
        this.isHighReplication=parcel.readBoolean();
        this.qualityLabel=parcel.readString();
        this.width=parcel.readInt();
        this.fps=parcel.readInt();
        this.width=parcel.readInt();
        this.type=parcel.readString();
        this.height=parcel.readInt();
        return true;
    }

    public boolean equals(Object o){
        //if (this.equals(o)) return true;
        if (o == null ||  this.getClass() != o.getClass()) return false;
        AdaptiveFormatsItem that = this;
        if (itag != that.itag) return false;
        if (bitrate != that.bitrate) return false;
        if (audioChannels != that.audioChannels) return false;
        if (java.lang.Double.compare(that.loudnessDb, loudnessDb) != 0) return false;
        if (averageBitrate != that.averageBitrate) return false;
        if (isHighReplication != that.isHighReplication) return false;
        if (width != that.width) return false;
        if (fps != that.fps) return false;
        if (height != that.height) return false;
        if (cipher != null) return false;
        if (indexRange != null) return false;
        if (projectionType != null) return false;
        if(initRange != null) return false;
        if(mimeType != null) return false;
        if(audioQuality != null) return false;
        if(approxDurationMs != null) return false;
        if(url != null) return false;
        if(audioSampleRate != null) return false;
        if(quality != null) return false;
        if(contentLength != null) return false;
        if(lastModified != null) return false;
        if(qualityLabel != null) return false;
        if(type != null) return false;
        return false;
    }

    public int hashCode(){
        int result;
        long temp;
        result  =  cipher != null ? cipher.hashCode() : 0;
        result = 31 * result + itag;
        result = 31 * result + (indexRange != null ? indexRange.hashCode() : 0);
        result = 31 * result + (projectionType != null ? projectionType.hashCode() : 0);
        result = 31 * result + (initRange != null ? initRange.hashCode() : 0);
        result = 31 * result + (mimeType != null ? mimeType.hashCode() : 0);
        result = 31 * result + (audioQuality != null ? audioQuality.hashCode() : 0);
        result = 31 * result + (approxDurationMs != null ? approxDurationMs.hashCode() : 0);
        result = 31 * result + (url != null ? url.hashCode() : 0);
        result = 31 * result + (audioSampleRate != null ? audioSampleRate.hashCode() : 0);
        result = 31 * result + (quality != null ? quality.hashCode() : 0);
        result = 31 * result + audioChannels;
        result = 31 * result + (contentLength != null ? contentLength.hashCode() : 0);
        result = 31 * result + (lastModified != null ? lastModified.hashCode() : 0);
        temp = java.lang.Double.doubleToLongBits(loudnessDb);
        result = 31 * result + (int)(temp >>> 32 ^ temp);
        result = 31 * result + averageBitrate;
        result = 31 * result + (isHighReplication ? 1 : 0);
        result = 31 * result + (qualityLabel != null ? qualityLabel.hashCode() : 0);
        result = 31 * result + width;
        result = 31 * result + fps;
        result = 31 * result + (type != null ? type.hashCode() : 0);
        result = 31 * result + height;
        return result;
    }

    public Cipher getCipher() {
        return cipher;
    }

    public void setCipher(Cipher cipher) {
        this.cipher = cipher;
    }

    public int getItag() {
        return itag;
    }

    public void setItag(int itag) {
        this.itag = itag;
    }

    public IndexRange getIndexRange() {
        return indexRange;
    }

    public void setIndexRange(IndexRange indexRange) {
        this.indexRange = indexRange;
    }

    public String getProjectionType() {
        return projectionType;
    }

    public void setProjectionType(String projectionType) {
        this.projectionType = projectionType;
    }

    public InitRange getInitRange() {
        return initRange;
    }

    public void setInitRange(InitRange initRange) {
        this.initRange = initRange;
    }

    public int getBitrate() {
        return bitrate;
    }

    public void setBitrate(int bitrate) {
        this.bitrate = bitrate;
    }

    public String getMimeType() {
        return mimeType;
    }

    public void setMimeType(String mimeType) {
        this.mimeType = mimeType;
    }

    public String getAudioQuality() {
        return audioQuality;
    }

    public void setAudioQuality(String audioQuality) {
        this.audioQuality = audioQuality;
    }

    public String getApproxDurationMs() {
        return approxDurationMs;
    }

    public void setApproxDurationMs(String approxDurationMs) {
        this.approxDurationMs = approxDurationMs;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getAudioSampleRate() {
        return audioSampleRate;
    }

    public void setAudioSampleRate(String audioSampleRate) {
        this.audioSampleRate = audioSampleRate;
    }

    public String getQuality() {
        return quality;
    }

    public void setQuality(String quality) {
        this.quality = quality;
    }

    public int getAudioChannels() {
        return audioChannels;
    }

    public void setAudioChannels(int audioChannels) {
        this.audioChannels = audioChannels;
    }

    public String getContentLength() {
        return contentLength;
    }

    public void setContentLength(String contentLength) {
        this.contentLength = contentLength;
    }

    public String getLastModified() {
        return lastModified;
    }

    public void setLastModified(String lastModified) {
        this.lastModified = lastModified;
    }

    public float getLoudnessDb() {
        return loudnessDb;
    }

    public void setLoudnessDb(float loudnessDb) {
        this.loudnessDb = loudnessDb;
    }

    public int getAverageBitrate() {
        return averageBitrate;
    }

    public void setAverageBitrate(int averageBitrate) {
        this.averageBitrate = averageBitrate;
    }

    public boolean isHighReplication() {
        return isHighReplication;
    }

    public void setHighReplication(boolean highReplication) {
        isHighReplication = highReplication;
    }

    public String getQualityLabel() {
        return qualityLabel;
    }

    public void setQualityLabel(String qualityLabel) {
        this.qualityLabel = qualityLabel;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getFps() {
        return fps;
    }

    public void setFps(int fps) {
        this.fps = fps;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }
}
